package com.example.monitoringsystem.controller;

import com.example.monitoringsystem.bean.Prescription;
import com.example.monitoringsystem.bean.User;
import com.example.monitoringsystem.service.PrescribeService;
import com.example.monitoringsystem.service.StatesService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class PrescribeController {

    @Autowired
    private PrescribeService prescribeService;

    @PostMapping("/prescribe")
    @ResponseBody
    public String prescribe(int patientId,@RequestBody List<Prescription>prescriptions){
        prescribeService.allPrescribe(patientId,prescriptions);
        return "添加成功";
    }
//@PostMapping("/prescribe")
//@ResponseBody
//public String prescribe(int patientId, Prescription prescriptions){
//    prescribeService.prescribe(patientId,prescriptions);
//    return "success";
//}

    //病人查看自己的处方
    @GetMapping("/patient/prescribe")
    @ResponseBody
    public Map showPatientPrescription(){
        return prescribeService.showPatientPrescription();
    }
}
